import React, { Component } from 'react';
import Button from '../Button'
class Index extends Component {
	state = {
		user: '',
		pwd: ''
	}
	handleSubmit(e) {
		e.preventDefault()

		this.props.onSubmit(this.state)
	}
	render() {
		const { user, pwd } = this.state
		return (
			// form submit 
			// 当表单元素内部 有button[type="submit"] 被点击的事件
			// 会触发表单  submit 事件
			<form onSubmit={ e => this.handleSubmit(e)}>
				<p>
					<span>用户名：</span>
					<input type="text"
						value={user}
						onChange={e => this.setState({ user: e.target.value })}
					/>
				</p>
				<p>
					<span>密码：</span>
					<input type="text"
						value={pwd}
						onChange={e => this.setState({ pwd: e.target.value })}
					/>
				</p>
				<Button type="dashed" danger>登录</Button>
			</form>
		);
	}
}

export default Index;
